<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


class Core_Form_User_Phone extends RedCross_Form
{
    public function init()
    {
        $this->addElement('text', 'phone', array(
            'filters'		=> array('StringTrim'),
            'validators'	=> array(
                array('Digits'),
                array('StringLength', true, array(8, 8)),
            ),
            'required' 	=> true,
            'label' 	=> 'Telefon'
        ));

	    $this->addElement('select', 'phonetype', array(
            'required' 	=> true,
            'label' 	=> 'Telefontype'
        ));

        $phonetypeService = RedCross_Factory::getService('Core_Service_Phonetype');
        $phonetypes = $phonetypeService->fetchAll();
        foreach($phonetypes as $p) {
            $this->getElement('phonetype')->addMultiOption($p->id, $p->name);
        }
        
        $this->addElement('hidden', 'submit_phone');
        $this->addElement('submit', 'submit', array(
            'required' => true,
            'ignore'    => true,
            'label'     => 'Legg til telefonnummer'
        ));
    }
}
